/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package chapter6;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

/**
 *
 * @author Denise Carolina
 */
public class SelfTest8 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        SpecialSerial ss = new SpecialSerial();
        try{

            ss.setTest("carolina");
            ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("myFile"));
            oos.writeObject(ss);
            oos.flush();
            oos.close();
            System.out.println(++ss.z + " ");

            ss.setTest("videtta lopez");
            ObjectInputStream ois = new ObjectInputStream(new FileInputStream("myFile"));
            SpecialSerial ss2 = (SpecialSerial)ois.readObject();
            ois.close();
            System.out.println(ss2.y + " " + SpecialSerial.z + " " + ss2.getTest());
        
        }catch(Exception e){

        }
    }

}

class SpecialSerial implements Serializable{
    transient int y = 7;
    static int z = 9;
    String test = "denise";

   String getTest(){
        return test;
   }

   void setTest(String newValue){
        test = newValue;
   }
}
